package cn.edu.cqu.bysj.wm.gui.component;

import java.awt.BorderLayout;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

import javax.swing.JPanel;
import javax.swing.JSplitPane;

import cn.edu.cqu.bysj.wm.gui.model.AlgorithmConfig;
import cn.edu.cqu.bysj.wm.gui.model.AlgorithmResult;

public abstract class AlgorithmTabPane extends JPanel {

	private String title;
	protected JSplitPane splitPane;
	protected double size = 1;
	protected AlgorithmConfig configure;
	protected AlgorithmResult result;

	/**
	 * create algorithm tab
	 * 
	 * @param _size
	 * @param _title
	 * @param _configure
	 */
	public AlgorithmTabPane(double _size, String _title,
			AlgorithmConfig _configure) {
		this.size = _size;
		this.setTitle(_title);
		this.setConfigure(_configure);
		setLayout(new BorderLayout(0, 0));
		splitPane = new JSplitPane();
		add(splitPane);

		splitPane.setDividerSize(4);
		this.addComponentListener(new ComponentAdapter() {
			@Override
			public void componentResized(ComponentEvent e) {
				splitPane.setDividerLocation(size);
			}
		});
	}

	public void setResult(AlgorithmResult result) {
		this.result = result;
	}

	public AlgorithmResult getResult() {
		return this.result;
	}

	public abstract void showResult();

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public AlgorithmConfig getConfigure() {
		return configure;
	}

	public void setConfigure(AlgorithmConfig configure) {
		this.configure = configure;
	}

}
